/*
 * Copyright (c) 2008 Ricardo Rocha, rocha.porto@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.gliding.kumulus.client;

import org.gliding.kumulus.client.model.KumulusContext;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * Class defining the Kumulus application.
 * 
 * From here all sub applications - planning, flight logging, ... - can
 * be launched.
 * 
 * @author Ricardo Rocha <rocha.porto@gmail.com>
 * @version $Rev:: $
 */
public class Kumulus implements EntryPoint {

    /**
     * The Kumulus application context, holding all the generic model data. 
     */
    private KumulusContext kumulusContext = KumulusContext.getKumulusContext();
    
	/**
	 * The container panel where all widgets are put.
	 */
    private VerticalPanel mainPanel = new VerticalPanel();
    
    /**
     * The header top panel.
     */
    private HorizontalPanel topPanel = new HorizontalPanel();
    
    /**
     * The label containing the active message.
     */
    private static Label messageLabel = new Label();
    
    /**
     * The planning widget we put in the content area.
     */
    private Planning planningWidget = new Planning();
    
	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
        topPanel.setStyleName("kumulus-Header");
        
		// Fill up the top panel and add it to the container panel
        SimplePanel logoPanel = new SimplePanel();
        logoPanel.setStyleName("kumulus-HeaderLogo");
        logoPanel.add(new Label("Logo Here"));
        topPanel.add(logoPanel);
        topPanel.setCellWidth(logoPanel, "20%");
        
        SimplePanel messagePanel = new SimplePanel();
        messagePanel.setStyleName("kumulus-HeaderMessage");
        messagePanel.add(messageLabel);
        topPanel.add(messagePanel);
        topPanel.setCellWidth(messagePanel, "50%");
        
        SimplePanel loginPanel = new SimplePanel();
        loginPanel.setStyleName("kumulus-HeaderLogin");
        loginPanel.add(new HTML("Login Area"));
        topPanel.add(loginPanel);
        topPanel.setCellWidth(loginPanel, "20%");
        
        mainPanel.add(topPanel);
        
        // Add the planning widget to the main panel
        mainPanel.add(planningWidget);
        
        // Set the overall CSS style of the application
        mainPanel.setStyleName("kumulus-Main");

        // Add the container panel to the root panel
        RootPanel.get("main").add(mainPanel);
	}
    
    public static void setMessage(String message) {
        Kumulus.messageLabel.setText(message);
    }
}